using System;
using System.Collections.Generic;
using System.Text;
using AF_ORM.CORE;
using System.Data;
namespace Tongiao.Manager
{
                

    public class Tg_NewsInfosManager:Tongiao.ManagerBase.Tg_NewsInfosManagerBase
    {
            public static Tg_NewsInfosManager CreateInstant()
            {
                return new Tg_NewsInfosManager();
            }

            public DataTable SearchNews(Guid CategoryId, string NewsName)
            {
                string sql = "select N.*,C.CatName from tg_NewsInfos as N inner join tg_Category as C on N.CategoryId = C.id ";
                if ((CategoryId != Guid.Empty) && NewsName.Equals(""))
                    sql += " where CategoryId = '" + CategoryId + "'";
                else if ((CategoryId == Guid.Empty) && !NewsName.ToString().Equals(""))
                    sql += " where title like N'%" + NewsName + "%'";
                else if ((CategoryId != Guid.Empty) && !NewsName.ToString().Equals(""))
                    sql += " where CategoryId = '" + CategoryId + "' and (title like N'%" + NewsName + "%') ";

                return SqlHelper.ExecuteDataTable(Config.ConnectionConfig.ConnectionString, CommandType.Text, sql);
            }

            public DataTable GetRandomNewsIndex()
            {
                string strSql = "select top 4 * from tg_NewsInfos ORDER BY NEWID()";
                return SqlHelper.ExecuteDataTable(Config.ConnectionConfig.ConnectionString,CommandType.Text, strSql);
            }

            public DataTable GetTopMasquee()
            {
                string strSql = "select top 10 * from tg_NewsInfos";
                return SqlHelper.ExecuteDataTable(Config.ConnectionConfig.ConnectionString,CommandType.Text,strSql);
            }
    }
}
                    
